
:root {
    --font-size: 1.2rem;
    /* --dpi-zoom: 0.96; */
    --deco-size: calc(var(--font-size) / 2);
    --line-height: calc(var(--font-size) / 2 * 3);
    --compact-menu-height: 2em;
    --span: 8px;
    --span-half: calc(var(--span) / 2);
    --span-double: calc(var(--span) * 2);
    --border: 1px;
    --border-double: calc(var(--border) * 2);
    --paper-width: 384px;
    --anim-time: 0.5s;
    --fore-color: #111;
    --back-color: #eee;
    --canvas-back: #fff;
    --panel-height: 20em;
    --target-color: rgba(0, 255, 255, 0.2);
    --notice-wait: rgba(0, 128, 255, 0.2);
    --notice-note: rgba(0, 255, 0, 0.2);
    --notice-warn: rgba(255, 128, 0, 0.2);
    --notice-error: rgba(255, 0, 0, 0.2);
    --shade: rgba(238, 238, 238, 0.5);
}
@media (prefers-color-scheme: dark) {
    :root { --fore-color: #eee; --back-color: #333; --shade: rgba(51, 51, 51, 0.5); }
    a:link, a:visited { color: #66f; }
    a:hover, a:active { color: #77f; }
    .canvas-group, .logo { opacity: 0.6; }
    #control-overlay { background-color: var(--shade); }
}
/* so silly... */
body.dark-theme { --fore-color: #eee; --back-color: #333; --shade: rgba(51, 51, 51, 0.5); }
body.dark-theme a:link, body.dark-theme a:visited { color: #66f; }
body.dark-theme a:hover, body.dark-theme a:active { color: #77f; }
body.dark-theme .canvas-group, body.dark-theme .logo { opacity: 0.6; }
body.dark-theme #control-overlay { background-color: var(--shade); }

body {
    border: none;
    background-color: var(--back-color);
    color: var(--fore-color);
    font-size: var(--font-size);
    line-height: var(--line-height);
    font-family: 'Noto Sans', 'Segoe UI', sans-serif;
    overflow: auto;
    margin: 1em 0;
    user-select: none;
}
body.android .hide-on-android {
    display: none;
}
* {
    box-sizing: border-box;
    transition-property: background-color, transform,/* box-shadow,*/ flex-grow, opacity;
    transition-delay: 0s;
    transition-duration: var(--anim-time);
    transition-timing-function: ease-out;
}
button, input[type="number"], input[type="text"], select,
#dialog>.shade, #dialog>.content, #canvas {
    transition-timing-function: cubic-bezier(.08,.82,.17,1);
}
#dialog>.shade {
    transition-duration: calc(var(--anim-time) / 2);
}
a {
    transition: color var(--anim-time) ease-out;
}
.selectable {
    user-select: all;
}
h1, h2 {
    font-weight: normal;
    margin: var(--span-half) 0;
}
h1 { font-size: 1.5em; }
h2 { font-size: 1.2em; }
a:link, a:visited {
    color: #33f;
}
a:hover, a:active {
    color: #22f;
}
a+a {
    margin-left: var(--font-size);
}

.center {
    text-align: center;
}
.right {
    text-align: end;
}
button, input, select, textarea, label {
    font: inherit;
    color: var(--fore-color);
    /* background-color: var(--back-color); */
    background-color: transparent;
    display: inline-block;
}
select[multiple] {
    width: 8em;
    padding: var(--border);
    margin: var(--span-half) var(--span);
}
button, input[type="number"], input[type="text"], select {
    margin: var(--span-half) var(--span);
    border: var(--border) solid var(--fore-color);
    padding: var(--span-half) var(--span);
    cursor: pointer;
    min-width: 6em;
    line-height: calc(var(--font-size) + var(--span));
}
input[type="number"], input[type="text"] {
    width: 6em;
    cursor: text;
}
button:hover {
    /*
    margin: 0;
    padding: var(--span) var(--span-double);
    min-width: calc(6em + var(--span-double));
    */
    transform: scale(1.1);
}
button:active {
    box-shadow: 0 0 var(--span) inset var(--fore-color);
}
.input-group {
    display: table;
    width: 100%;
}
.label-span-input {
    display: table-row;
    margin: var(--span-half) var(--span);
}
.label-span-input>:nth-child(1) {
    display: table-cell;
    min-width: 5em;
    padding: 0 var(--span);
    text-align: end;
}
.label-span-input>:nth-child(2) {
    display: table-cell;
    min-width: 6em;
    text-align: start;
}
.label-input-span {
    display: block;
    margin: var(--span-half) var(--span);
}
.label-input-span>:nth-child(1) {
    display: inline-block;
    padding: 0 var(--span);
    text-align: end;
}
.label-input-span>:nth-child(2) {
    display: inline-block;
    text-align: start;
}
@keyframes notice-fade {
    to { background-color: transparent; border-color: transparent; }
}
@keyframes notice-wait {
    50% { background-color: transparent; border-color: transparent; }
}
#notice {
    min-height: var(--font-size);
    margin: var(--span-half) 0;
}
#notice span {
    display: block;
}
#notice .note {
    background-color: var(--notice-note);
    animation: notice-fade 1s ease-out 1s 1 forwards;
}
#notice .wait {
    background-color: var(--notice-wait);
    animation: notice-wait 2s ease-in-out 0s infinite forwards;
}
#notice .warn {
    background-color: var(--notice-warn);
    animation: notice-fade 1s ease-out 1s 1 forwards;
}
#notice .error {
    background-color: var(--notice-error);
    animation: notice-fade 1s ease-out 1s 1 forwards;
}
#button-exit {
    background-color: var(--notice-warn);
}
.noscript {
    margin: var(--span-double);
    text-align: center;
    background-color: var(--notice-error);
    display: block;
}
main, header, footer {
    max-width: 45em;
    margin: 1em auto;
    display: flex;
    justify-content: space-between;
    flex-direction: row;
    /* overflow-x: hidden; */ /* this causes sticky position not work */
}
.canvas-side {
    flex-grow: 0;
    width: var(--paper-width);
    margin: var(--span) calc((50% - var(--paper-width)) / 2);
}
.canvas-side>* {
    text-align: center;
}
.menu-side {
    flex-grow: 1;
    position: sticky;
    top: 0;
    height: 100%;
    /* overflow: auto; */
    margin: var(--span) 0;
    min-width: 20em;
    /* width: 50%; */
}
.menu-side>.menu {
    border: var(--border) solid var(--fore-color);
    border-bottom: none;
    margin-top: var(--span);
}
.canvas-side>.buttons {
    position: sticky;
    bottom: 0;
    padding: var(--span) 0;
    background-color: var(--back-color);
    z-index: 1;
}
.compact-menu {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    background-color: var(--back-color);
}
.compact-button {
    height: var(--compact-menu-height);
    line-height: var(--compact-menu-height);
    text-align: center;
    cursor: pointer;
    border: none;
    border-top: var(--border) solid var(--fore-color);
    border-bottom: var(--border) solid transparent;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}
.compact-button:hover {
    transform: unset;
    flex-grow: 1.2;
}
.compact-button.active {
    border: var(--border) solid var(--fore-color);
    border-top: var(--border) solid transparent;
}
#canvas, #preview {
    border: var(--border) solid var(--fore-color);
    background-color: var(--canvas-back);
    width: var(--paper-width);
    display: inline-block;
}
#preview {
    z-index: 0;
}
#canvas {
    position: absolute;
    opacity: 0;
    z-index: 1;
}
#canvas:hover {
    opacity: 1;
}
.canvas-group>*.disabled {
    display: none;
}
#control-overlay {
    position: absolute;
    z-index: 2;
    display: inline-block;
    /* width: calc(var(--paper-width) + var(--border-double)); */
    width: var(--paper-width);
    margin-top: 0.5em;
}
p {
    margin: var(--span) 0;
}
.panel {
    overflow: hidden;
    height: 0;
}
.panel.active {
    height: calc(var(--panel-height) - var(--compact-menu-height));
    padding: var(--span-double) var(--span);
    overflow-y: auto;
}
.panel.sub.active {
    height: calc(var(--panel-height) / 2);
}
input[type="range"] {
    width: 10em;
    vertical-align: middle;
    content: attr(value);
}
@keyframes hint {
    0% { box-shadow: 0 0 var(--span-) inset transparent; }
    50% { box-shadow: 0 0 var(--span) inset var(--fore-color); }
    100% { box-shadow: 0 0 var(--span) inset transparent; }
}
.hint {
    animation: hint 3s ease-out 0.1s infinite;
}
.hidden {
    /* visibility: hidden; */
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}
#hidden, .hard-hidden {
    display: none;
}
#hint-tab-control {
    position: relative;
}
#error-record {
    font-family: 'DejaVu Sans Mono', 'Consolas', monospace;
    width: 100%;
    font-size: 1rem;
    line-height: initial;
    overflow: auto;
    white-space: pre;
    height: calc(var(--panel-height) - var(--border-double) * 4);
}
#error-record *::selection {
    background-color: var(--notice-wait);
}
.table-wrap {
    overflow-x: auto;
    width: 100%;
}
table#jslicense-labels1 {
    min-width: 40em;
}
table#jslicense-labels1 td {
    padding: var(--span-half) var(--span);
    white-space: nowrap;
}
table#jslicense-labels1 td:nth-child(4) {
    white-space: normal;
    width: 50vw;
}
*:target {
    background-color: var(--target-color);
}
dl {
    margin: var(--span) 0;
    display: block;
}
dt { display: inline-block; min-width: 6em; text-align: end; }
dd { display: inline-block; margin: 0 calc(var(--font-size) / 4); }
.contributors dt {
    min-width: 12em;
    text-align: center;
    padding: 0 calc(var(--font-size) / 4);
    border-right: var(--border) solid var(--fore-color);
}
hr {
    border: none;
    border-top: var(--border) solid var(--fore-color);
}
iframe#frame {
    width: 100%;
    height: 60vh;
    border: none;
    background-color: transparent;
}
.blank {
    height: 0em;
}
.shade {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: var(--back-color);
    opacity: 0.95;
    z-index: -1;
}
#dialog {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    text-align: center;
    z-index: 2;
    opacity: 1;
}
#dialog>.content {
    max-width: 100%;
    width: 42em;
    max-height: 100vh;
    margin: 12vh auto;
    border: var(--border) solid var(--fore-color);
    transform-origin: center 33%;
}
#dialog.hidden {
    opacity: 0;
}
#dialog.hidden>.content {
    transform: scaleY(0);
}
#dialog-content {
    margin: auto;
    padding: var(--span-double);
    padding-bottom: 0;
    max-height: calc(76vh - 1em);
    overflow-y: auto;
}
#dialog-choices {
    margin: auto;
    padding: var(--span);
    padding-top: 0;
    position: sticky;
    bottom: 0;
}
#choice-input {
    max-width: 100%;
    width: 16em;
}
#accessibility {
    text-align: initial;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    flex-wrap: wrap;
}
#select-language {
    /* width: calc(100% - var(--span-double)); */
    width: 100%;
    height: 8em;
    border: var(--border) solid var(--fore-color);
    padding: var(--span);
    margin: 0 var(--span);
    overflow: auto;
}
#select-language option {
    cursor: pointer;
}
#select-language option:hover {
    text-decoration: underline;
}
#accessibility>* {
    flex-grow: 0;
    min-width: 16em;
    white-space: nowrap;
    margin: 1em;
}
@keyframes jump {
    0% { transform: translateY(0); }
    50% { transform: translateY(var(--font-size)); }
    100% { transform: translateY(0); }
}
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--back-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    z-index: 3;
    opacity: 1;
    transition-duration: 0.2s;
}
.logo {
    background-image: url('icon.svg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 80%;
    max-width: 16em;
    height: 80%;
    max-height: 16em;
    margin: 0 auto;
}
#loading-screen.hidden {
    opacity: 0;
}
#loading-screen>.dots {
    display: flex;
    flex-direction: row;
    justify-content: center;
}
#loading-screen>.dots>span {
    display: inline-block;
    width: var(--font-size);
    height: var(--font-size);
    margin: var(--font-size);
    background-color: var(--fore-color);
    border-radius: var(--font-size);
    animation: jump 1s ease 0s infinite;
}
#loading-screen>.dots>span:nth-child(1) { animation-delay: 0s; }
#loading-screen>.dots>span:nth-child(2) { animation-delay: 0.3s; }
#loading-screen>.dots>span:nth-child(3) { animation-delay: 0.6s; }

#keyboard-shortcuts-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    overflow: visible;
    pointer-events: all;
    z-index: 2;
}
#keyboard-shortcuts-layer span {
    display: inline-block;
    position: absolute;
    /* border: var(--border) dotted var(--fore-color); */
    background-color: var(--shade);
    padding: var(--span-half) var(--span);
    white-space: pre;
    line-height: 1em;
    font-family: 'DejaVu Sans Mono', 'Consolas', monospace;
    transform: translate(-1em, calc(var(--font-size) * -1));
}

@keyframes delay-scrollable {
    from { overflow: hidden; }
    to { overflow: auto; }
}

@media (max-height: 520px) {
    body, main { margin: 0 auto; }
}

@media (max-width: 767.5px) {
    /* My test shows it's Just 768 fit best */
    :root {
        --panel-height: 16em;
        --font-size: 1em;
    }
    main {
        flex-direction: column;
    }
    #title { display: none; }
    .canvas-side {
        min-width: unset;
        margin: 0;
        width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        position: fixed;
        top: calc(var(--line-height) + var(--span));
        height: calc(100% - var(--panel-height) - var(--compact-menu-height));
        z-index: 0;
    }
    .canvas-side>.buttons,
    .menu-side>.buttons {
        width: 100%;
    }
    #control-overlay {
        width: 100%;
        margin: 0;
    }
    .menu-side {
        overflow-x: hidden;
        overflow-y: auto;
        position: fixed;
        background-color: var(--back-color);
        top: unset;
        bottom: 0;
        left: 0;
        height: var(--panel-height);
        margin: 0;
        width: 100%;
        box-sizing: border-box;
    }
    .menu-side>.menu {
        height: calc(var(--panel-height) - var(--compact-menu-height));
        margin: 0;
    }
    #notice {
        position: fixed;
        top: 0;
        width: 100%;
    }
    .menu-side>.compact-menu {
        position: fixed;
        bottom: 0;
        width: 100%;
        z-index: 0;
    }
    #dialog-content {
        padding: var(--span) 0;
    }
    .blank {
        height: var(--compact-menu-height);
    }
}
@media (max-width: 385px) {
    #preview, #canvas, #control-overlay, .canvas-side>* {
        width: 100%;
        border: none;
        box-sizing: border-box;
    }
}

@media (prefers-reduced-motion) {
    body *,
    body *::before,
    body *::after {
        transition-duration: 0s !important;
        animation-duration: 0s !important;
        transition-timing-function: steps(1) !important;
        animation-timing-function: steps(1) !important;
    }
}
body.no-animation,
body.hard-animation,
body.no-animation *,
body.hard-animation *:not(#loading-screen, #loading-screen *),
body.no-animation *::before,
body.no-animation *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    transition-timing-function: steps(1) !important;
    animation-timing-function: steps(1) !important;
}

body.large-font,
#large-font+label {
    font-size: calc(var(--font-size) * 1.2);
    line-height: calc(var(--line-height) * 1.2);
}

body.force-rtl,
#force-rtl+label {
    direction: rtl;
}
.force-ltr {
    direction: ltr;
}
body.high-contrast {
    --border: 2px;
    --fore-color: #fff;
    --back-color: #000;
    --target-color: transparent;
    --notice-wait: transparent;
    --notice-note: transparent;
    --notice-warn: transparent;
    --notice-error: transparent;
    --shade: rgba(0, 0, 0, 0.8);
    transition-duration: 0s;
}
body.high-contrast .shade { transition-duration: 0s; opacity: 1; }
/* body.high-contrast * { background-color: var(--back-color); } */
body.high-contrast .logo, body.high-contrast .canvas-group { opacity: 1 !important; }
body.high-contrast #notice * { border: var(--border) dashed var(--fore-color); }
body.high-contrast a:any-link { color: #00f; }
body.high-contrast #control-overlay { background-color: var(--shade); }

/*
@font-face {
    font-family: 'Unifont';
    src: local('Unifont') url('unifont.ttf') url('unifont.otf');
}
*/
#insert-text-area { 
    white-space: pre;
    height: calc(60vh - 8em);
    width: var(--paper-width);
    overflow: hidden auto;
    white-space: break-spaces;
    resize: none;
    padding-top: .65ex;
    line-height: 1.25;
    border: var(--border) solid currentColor;
}

.text-align-container span {
    padding: 0px;
    margin: 0;
    display: inline-block;
}
.text-align-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 25px;
    width: 25px;
}

.text-align-checkmark {
    /* position: absolute; */
    background-repeat: no-repeat;
    background-image: url("icons/text-left.svg)");
    background-position: center;
    background-size: 90%;
    width: 25px;
    height: 25px;
    min-width: 25px;
    border: var(--border) solid var(--fore-color);
    padding: var(--span-half) var(--span);
}
.text-align-container input:checked ~ .text-align-checkmark {
    background-color: whitesmoke;
  }
.text-align-left { background-image: url("icons/text-left.svg")}
.text-align-center { background-image: url("icons/text-center.svg")}
.text-align-right { background-image: url("icons/text-right.svg")}

input[name="wrap-words-by-spaces"] { margin-right: 5px; }
#text-settings {
    display: flex;
    flex-direction: column;
}
.text-settings-group {
    margin-top: 1rem;
}
.text-settings-group[name="wrap-and-align"] {
    display: flex;
    justify-content: center;
}
label[name="wrap-words-by-spaces-label"] { padding-right: 2%; }
#text-font { height: 100%; margin: 0px; }